package org.boticelli.model;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@NamedQueries(value = { @NamedQuery(name = "SeenEntry.findByNick", query = "select s from SeenEntry s where lower(s.nick) = :name") })
@Entity
@Table(name = "seen")
@Cache(usage=CacheConcurrencyStrategy.NONE)
public class SeenEntry
        implements Serializable
{
    private static final long serialVersionUID = -7740652744264623688L;

    private Long id;

    private String nick;
    
    private Timestamp lastSeen;
    
    private String lastMessage;
   
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId()
    {
        return id;
    }

    @Column(unique = true)
    public String getNick()
    {
        return nick;
    }

    @Column(nullable=true)
    public Timestamp getLastSeen()
    {
        return lastSeen;
    }
    
    @Column(nullable=true)
    public String getLastMessage()
    {
        return lastMessage;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public void setNick(String name)
    {
        this.nick = name;
    }

    public void setLastMessage(String lastMessage)
    {
        this.lastMessage = lastMessage;
    }
    
    public void setLastSeen(Timestamp lastSeen)
    {
        this.lastSeen = lastSeen;
    }
}
